<template>
    <div class="word-card" :background="background" v-on:click="wordCardClickHandler">
        <div class="content">
            <h2>{{ spell }}</h2>
            <p>{{ explanation }}</p>
        </div>
    </div>
</template>

<script>
    export default {
        name: "WordCard",
        data() {
            return {
                background: 1
            }
        },
        props: {
            spell: {
                type: String,
                required: true
            },
            explanation: {
                type: String,
                required: true
            }
        },
        methods: {
            wordCardClickHandler: function () {
                if (this.background < 3) {
                    this.background++;
                } 
            }
        }
    }
</script>

<style scoped>
    .word-card {
        border-radius: 5px;
        cursor: pointer;
        position: relative;
        width: 100%;
        padding-bottom: 100%;
        box-shadow: 0 0 13px rgb(94 109 89 / .6);
    }

    .word-card .content {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 16px;
        box-sizing: border-box;
    }

    .word-card h2 {
        margin: 0;
    }

    .word-card p {
        margin: 0;
    }

    .word-card[background="1"] {
        background: antiquewhite;
    }

    .word-card[background="2"] {
        background: aliceblue;
    }

    .word-card[background="3"] {
        background: aquamarine;
        cursor: unset;
    }

</style>